//
//  ServiceAssignedViewController.m
//  HondaPro_2
//
//  Created by ht on 13-7-1.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "ServiceAssignedViewController.h"
#import "getJobSheetViewController.h"

#import "HJWorkOrderlistModel.h"
#import "HJRepairOrderInfoModel.h"

#import <QuartzCore/QuartzCore.h>
#import "UIViewController+MJPopupViewController.h"
#import "webConfig.h"
#import "webService.h"
#import "MJRefresh.h"
#import "MyAFNetWorkManager.h"

@interface ServiceAssignedViewController ()<ServiceCompileViewControllerDelegate>
{
    BOOL _ShaBiZhaoShaoFeiOne;
    BOOL _ShaBiZhaoShaoFeiTow;
    BOOL _ShaBiZhaoShaoFeiTheer;
    
    NSMutableArray *jiedaiguwenIDArr;
    NSMutableArray *gongdanzhuangtaiIDArr;
    NSString *selectJiedaiyuanID;
    NSString *selectGongdanzhuangtaiID;
    NSInteger ToID;
}

@property(nonatomic,strong)UITextField *chepaiField;
@property(nonatomic,strong)UITextField *chejiaField;
@property(nonatomic,strong)UITextField *workOrderField;
@property(nonatomic,strong)UIButton *jiedaiyuanBtn;
@property(nonatomic,strong)UIButton *gongdanzhuangtaiBtn;
@property(nonatomic,strong)UIButton *queryBtn;
/**
 贺佳:新建的模型 可以使用以前的偏好设置数据，也可以使用我的这个模型数组
 */
@property(nonatomic,strong)NSMutableArray*workOrderlistAry;
/**
 当前用户选择的时间按钮
 */
@property(nonatomic,strong)UIButton*currentBtn;
/**
 开工单开始时间
 */
@property(nonatomic,weak)UIButton*startTimebutton;
/**
 开工单结束时间
 */
@property(nonatomic,weak)UIButton*endTimebutton;
@end

@implementation ServiceAssignedViewController

@synthesize ServiceTableView = _ServiceTableView;
@synthesize TimeZoneTableView = _TimeZoneTableView;
@synthesize TimeZoneBanJin = _TimeZoneBanJin;
@synthesize TimeZonePenQi = _TimeZonePenQi;

@synthesize serviceScrollView = _serviceScrollView;
@synthesize transverseScrollView = _transverseScrollView;
@synthesize tableViewCellLabel = _tableViewCellLabel;

@synthesize chooseTableButton1 = _chooseTableButton1;
@synthesize chooseTableButton2 = _chooseTableButton2;
@synthesize chooseTableButton3 = _chooseTableButton3;
@synthesize chooseTableButton4 = _chooseTableButton4;

@synthesize paigongButton = _paigongButton;

//派工信息列表字典
@synthesize serviceTable = _serviceTable;
@synthesize serviceTableArrayone = _serviceTableArrayone;
@synthesize serviceTableArraytwo = _serviceTableArraytwo;
@synthesize serviceTableArraythree = _serviceTableArraythree;
@synthesize serviceTableArrayfour = _serviceTableArrayfour;
@synthesize serviceTableArrayfive = _serviceTableArrayfive;
@synthesize serviceTableArraysix = _serviceTableArraysix;
@synthesize serviceTableArrayseven = _serviceTableArrayseven;
@synthesize serviceTableArrayeight = _serviceTableArrayeight;
@synthesize serviceTableArraynine = _serviceTableArraynine;
//deta
@synthesize listRowCollection = _listRowCollection;

@synthesize passDictionary = _passDictionary;

@synthesize gongweipaiLabel = _gongweipaiLabel;
@synthesize gongweipaiView = _gongweipaiView;
@synthesize workStationNameArray = _workStationNameArray;
@synthesize workStationNameLabel = _workStationNameLabel;
-(NSMutableArray *)workOrderlistAry
{
    if (!_workOrderlistAry) {
        _workOrderlistAry=[NSMutableArray array];
    }
    return _workOrderlistAry;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        
        
        
        /////////////直接请求
//        [self addNotification];
//        webService *webcon = [[webService alloc]init];
//        webcon.methodName = GETDISPATCHINGLIST;
//        [webcon commonGetSharedRequest:GETDISPATCHINGLIST wsparas:self.listRowCollection];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    jiedaiguwenIDArr = [NSMutableArray arrayWithCapacity:4];
    gongdanzhuangtaiIDArr = [NSMutableArray arrayWithCapacity:4];
    self.listRowCollection = [NSMutableArray arrayWithCapacity:4];
    [self loadtableViewPicture];//两个表格，两个滚动背景，三个派工层
    
    [self loadbasicbuttonPicture];
    [self loadNewTitleLabelPicture];
    //[self loadSecondPartPicture];
    //[self loadCallButtonPicture];

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(cancelButtonClicked:) name:@"cancelButtonClicked" object:nil];
    
    
    ToID = 10;
    //[self chooseTableButton1:self.chooseTableButton1];
}

-(void)viewWillAppear:(BOOL)animated
{
//    NSLog(@"to-----%d",ToID);
    [self firastRequest];
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    //判断是否是由接待服务的“维修派工跳转而来”
    if ([self.jumpByServiceUI isEqualToString:@"jumpByServiceUI"])
    {
        [self paigongBtnJumpedByServiceUIPressed];
    }
}

- (void)firastRequest
{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:5];
    
    [dic setValue:[self.chepaiField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"VIN"];
    [dic setValue:[self.chejiaField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"LICENSE"];
    [dic setValue:selectJiedaiyuanID forKey:@"SERVICE_ADVISOR"];
    [dic setValue:selectGongdanzhuangtaiID forKey:@"RO_DETAIL_STATUS"];
     [dic setValue:self.workOrderField.text forKey:@"RO_NO"];
    
    if (![self.startTimebutton.currentTitle containsString:@"选择"]) {
        [dic setValue:self.startTimebutton.currentTitle forKey:@"RO_START_DATE"];
    }
    if (![self.endTimebutton.currentTitle containsString:@"选择"]) {
        [dic setValue:self.endTimebutton.currentTitle forKey:@"RO_END_DATE"];
    }
    
//    [dic setValue:[NSString stringWithFormat:@"%d",self.listRowCollection.count+1] forKey:@"FROM"];
//    [dic setValue:[NSString stringWithFormat:@"%d",self.listRowCollection.count+10] forKey:@"TO"];
    
    [dic setValue:@"1" forKey:@"FROM"];
    [dic setValue:[NSString stringWithFormat:@"%zd",ToID] forKey:@"TO"];
    NSLog(@"工单查询 %@---",dic);
    
    [SVProgressHUD showWithStatus:@"请等待..."];
    [MyAFNetWorkManager postWithParam:dic andAction:@"QUERY_REPAIR_ORDER_DETAIL_FOR_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
        [SVProgressHUD dismiss];
        
        
        if (!error) {
            NSLog(@"维修派工查询:%@",obj);
            NSNumber *success = obj[@"SUCCESS"];
            [self.listRowCollection removeAllObjects];
            [self.workOrderlistAry removeAllObjects];
            if (success.integerValue==1) {
                
                [self.workOrderlistAry addObjectsFromArray:[HJWorkOrderlistModel mj_objectArrayWithKeyValuesArray:obj[@"TT_REPAIR_ORDER"]]];
                [self.listRowCollection addObjectsFromArray:[obj valueForKey:@"TT_REPAIR_ORDER"]];
                
                [self.ServiceTableView.mj_footer endRefreshing];
                [self.ServiceTableView.mj_header endRefreshing];
                [self.ServiceTableView reloadData];
            }
        }
        else{
            [SVProgressHUD dismiss];

            [SVProgressHUD showErrorWithStatus:error.localizedDescription];
        }
        
    }];
}

-(void)showTime
{
    NSDate *datenow = [NSDate date];
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSInteger interval = [zone secondsFromGMTForDate: datenow];
    NSDate *dateE = [datenow dateByAddingTimeInterval: interval];
    NSString *timeString=[NSString stringWithFormat:@"%@",dateE ];
    NSString *hour=[timeString substringWithRange:NSMakeRange(11, 3)];
    NSString *minute=[timeString substringWithRange:NSMakeRange(14, 2)];
    
    for (UIView *view in self.transverseScrollView.subviews)
    {
        if(view.tag==[hour intValue])
        {
            
            for (UILabel *label in view.subviews)
            {
                [label setCenter:CGPointMake(view.bounds.size.width/60*[minute intValue], view.bounds.size.height/2)];
            }
            [view setHidden:NO];
        }
    }
}

-(void)getDispatchinglist:(NSNotification *)notification
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
    self.listRowCollection = [theJson objectForKey:@"dispatchingList"];
    [self.ServiceTableView reloadData];
}

#pragma mark - tableView和两个scrollView
-(void)loadtableViewPicture
{
    self.serviceScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 1024,768)];
    self.serviceScrollView.contentSize = CGSizeMake(1, 1);//CGSizeMake(1024,768+300+[self.workStationLabelArray count]*45);
    [self.serviceScrollView setBackgroundColor:[UIColor whiteColor]];
    self.serviceScrollView.pagingEnabled = NO;
    self.serviceScrollView.showsVerticalScrollIndicator = YES;
    self.serviceScrollView.delegate = self;
    [self.view addSubview:self.serviceScrollView];
//
//    self.transverseScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(150, 450, 820, 300)];
//    self.transverseScrollView.contentSize = CGSizeMake(100*16,300);
//    [self.transverseScrollView setBackgroundColor:[UIColor whiteColor]];
//    self.transverseScrollView.pagingEnabled = NO;
//    self.transverseScrollView.showsVerticalScrollIndicator = YES;
//    self.transverseScrollView.delegate = self;
//    [self.serviceScrollView addSubview:self.transverseScrollView];
//    //取当前时间判断进入派工页面时左右滚动视图的显示坐标
//    NSDate *datenow = [NSDate date];
//    NSTimeZone *zone = [NSTimeZone systemTimeZone];
//    NSInteger interval = [zone secondsFromGMTForDate: datenow];
//    NSDate *dateE = [datenow dateByAddingTimeInterval: interval];
//    NSString *timeString=[NSString stringWithFormat:@"%@",dateE ];
//    NSString *hour=[timeString substringWithRange:NSMakeRange(11, 3)];
//    float floatHour = [hour floatValue];
//    if(floatHour > 12)
//    {
//        
//        [self.transverseScrollView scrollRectToVisible:CGRectMake(820, 0, self.transverseScrollView.frame.size.width, self.transverseScrollView.frame.size.height) animated:NO];
//    }
    
    self.ServiceTableView = [[UITableView alloc]initWithFrame:CGRectMake(54, 310, 919, 768-250) style:UITableViewStylePlain];
    
    [self.ServiceTableView setDataSource:self];
    [self.ServiceTableView setDelegate:self];
    [self.serviceScrollView addSubview:self.ServiceTableView];
    self.serviceScrollView.scrollEnabled = NO;
    
    __unsafe_unretained UITableView *tableView = self.ServiceTableView;
    
    // 下拉刷新
    tableView.mj_header= [MJRefreshNormalHeader headerWithRefreshingBlock:^{
//        [self.listRowCollection removeAllObjects];
        ToID = 10;
        [self firastRequest];
    }];
    
    // 设置自动切换透明度(在导航栏下面自动隐藏)
    tableView.mj_header.automaticallyChangeAlpha = YES;
    
    // 上拉刷新
    tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        ToID = ToID+10;
        [self firastRequest];
    }];
    
    
    //时间轴表格
    self.TimeZoneTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 30, 1600, 0) style:UITableViewStylePlain];
    [self.TimeZoneTableView setDataSource:self];
    [self.TimeZoneTableView setDelegate:self];
    [self.transverseScrollView addSubview:self.TimeZoneTableView];
    
    self.jiXiuBackground = [[UIView alloc]initWithFrame:CGRectMake(0, 30, 1600, 450)];//机修视图派工层
    self.jiXiuBackground.backgroundColor = [UIColor clearColor];
    [self.jiXiuBackground setHidden:NO];
    [self.transverseScrollView addSubview:self.jiXiuBackground];
    
    self.banJinBackground = [[UIView alloc]initWithFrame:CGRectMake(0, 30, 1600, 450)];//钣金视图派工层
    self.banJinBackground.backgroundColor = [UIColor clearColor];
    [self.banJinBackground setHidden:YES];
    [self.transverseScrollView addSubview:self.banJinBackground];
    
    self.penQiBackground = [[UIView alloc]initWithFrame:CGRectMake(0, 30, 1600, 450)];//喷漆视图派工层
    self.penQiBackground.backgroundColor = [UIColor clearColor];
    [self.penQiBackground setHidden:YES];
    [self.transverseScrollView addSubview:self.penQiBackground];
}

#pragma mark - 界面固定按钮与图片
-(void)loadbasicbuttonPicture
{
    self.homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.homeButton setImage:[UIImage imageNamed:@"房子.png"] forState:UIControlStateNormal];
    [self.homeButton setFrame:CGRectMake(70, 42, 68, 40)];
    [self.homeButton addTarget:self action:@selector(homeButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.serviceScrollView addSubview:self.homeButton];
    UIImageView *image1 = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 1000, 11)];
    image1.image = [UIImage imageNamed:@"渐变分割线.png"];
    [self.serviceScrollView addSubview:image1];
    
    UILabel *jiedai = [[UILabel alloc]initWithFrame:CGRectMake(200, 45, 200, 40)];
    jiedai.text = @"工单查询";
    jiedai.backgroundColor = [UIColor clearColor];
    jiedai.textColor = [UIColor grayColor];
    jiedai.font = [UIFont systemFontOfSize:30];
    [self.serviceScrollView addSubview:jiedai];
    
    self.queryBtn = [[UIButton alloc]initWithFrame:CGRectMake(870, 75, 75, 35)];
    [self.queryBtn setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.queryBtn setTitle:@"查  询" forState:UIControlStateNormal];
    [self.queryBtn setTintColor:[UIColor whiteColor]];
    self.queryBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.queryBtn addTarget:self action:@selector(query:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.queryBtn];
    
    
    [self createLabelWithTitle:@"车牌号:" fontSize:17 frame:CGRectMake(70, 130, 80, 35)];
    [self createLabelWithTitle:@"车架号:" fontSize:17 frame:CGRectMake(510, 130, 100, 35)];
    [self createLabelWithTitle:@"工单状态:" fontSize:17 frame:CGRectMake(70, 170, 80, 35)];
    [self createLabelWithTitle:@"服务专员:" fontSize:17 frame:CGRectMake(510, 170, 100, 35)];
    [self createLabelWithTitle:@"工单号:" fontSize:17 frame:CGRectMake(70, 210, 80, 35)];
    [self createLabelWithTitle:@"开单日期:" fontSize:17 frame:CGRectMake(510, 210, 100, 35)];
    
    //
    //CGRectMake(770, 195, 135, 35)
    UILabel*startTimelabel = [[UILabel alloc]initWithFrame:CGRectMake(610,210, 150, 35)];
    [startTimelabel setBackgroundColor:[UIColor whiteColor]];
    startTimelabel.layer.borderColor = [[UIColor grayColor]CGColor];
    startTimelabel.layer.borderWidth = 0.8;
    [self.serviceScrollView addSubview:startTimelabel];
    
    UIButton*startTimebutton = [[UIButton alloc]initWithFrame:CGRectMake(611,211, 148, 33)];
    [startTimebutton setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    startTimebutton.tag=99;
    [startTimebutton addTarget:self action:@selector(clickSelectDate:) forControlEvents:UIControlEventTouchUpInside];
    [startTimebutton setTitle:@"请选择" forState:UIControlStateNormal];
    startTimebutton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [startTimebutton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.serviceScrollView addSubview:startTimebutton];
    self.startTimebutton=startTimebutton;
    //默认开始时间是今天
    self.currentBtn=startTimebutton;
    [self selectToday:nil];
    
    //至
    UILabel*zhiLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(startTimebutton.frame), startTimebutton.mj_y, 50, startTimebutton.mj_h)];
    zhiLabel.textAlignment=NSTextAlignmentCenter;
    [self.serviceScrollView addSubview:zhiLabel];
    zhiLabel.text=@"至";
    zhiLabel.font=HJFont(15);
    //CGRectMake(600, 195, 132, 35)
    UILabel*endTimelabel = [[UILabel alloc]initWithFrame:CGRectMake(810,210, 150, 35)];
    [endTimelabel setBackgroundColor:[UIColor whiteColor]];
    endTimelabel.layer.borderColor = [[UIColor grayColor]CGColor];
    endTimelabel.layer.borderWidth = 0.8;
    [self.serviceScrollView addSubview:endTimelabel];
    //CGRectMake(601, 196, 130, 33)
    UIButton*endTimeButton = [[UIButton alloc]initWithFrame:CGRectMake(811,211, 148, 33)];
    [endTimeButton setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    endTimeButton.tag=100;
    [endTimeButton addTarget:self action:@selector(clickSelectDate:) forControlEvents:UIControlEventTouchUpInside];
    [endTimeButton setTitle:@"请选择" forState:UIControlStateNormal];
    endTimeButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [endTimeButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.endTimebutton=endTimeButton;
    [self.serviceScrollView addSubview:endTimeButton];
    
    self.chejiaField = [self setupTextFieldWithFrame:CGRectMake(150, 130, 350, 35)];// 车牌号
    self.workOrderField = [self setupTextFieldWithFrame:CGRectMake(150, 210, 350, 35)];// 工单号
    self.chepaiField = [self setupTextFieldWithFrame:CGRectMake(610, 130, 350, 35)];//车架号
    
    [self setupDropdownLabelWithFrame:CGRectMake(150, 170, 350, 35)];   //工单状态
    self.gongdanzhuangtaiBtn = [self setupDropdownButtonWithFrame:CGRectMake(151, 171, 348, 33) action:@selector(settlementbutton2:)];
    
    
    [self setupDropdownLabelWithFrame:CGRectMake(610, 170, 350, 35)]; //接待员
    self.jiedaiyuanBtn = [self setupDropdownButtonWithFrame:CGRectMake(611, 171, 348, 33) action:@selector(settlementbutton3:)];
}
-(void)clickSelectDate:(UIButton*)btn
{
    self.currentBtn=btn;
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(selectDateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 200.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(20, 0, 10, 40) inView:btn permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    UIButton *pickerBut = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [pickerBut setBackgroundColor:[UIColor clearColor]];
    [pickerBut setTitle:@"今 天" forState:UIControlStateNormal];
    [pickerBut setFrame:CGRectMake(20, 165, 80, 30)];
    [pickerBut addTarget:self action:@selector(selectToday:) forControlEvents:UIControlEventTouchUpInside];
    [panleCon.view addSubview:pickerBut];
    UIButton *pickerBut1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [pickerBut1 setBackgroundColor:[UIColor clearColor]];
    [pickerBut1 setTitle:@"清 除" forState:UIControlStateNormal];
    [pickerBut1 setFrame:CGRectMake(180, 165, 80, 30)];
    [pickerBut1 addTarget:self action:@selector(selectClearDate:) forControlEvents:UIControlEventTouchUpInside];
    [panleCon.view addSubview:pickerBut1];
    
}
-(void)selectDateChanged:(id)sender{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    self.dateString = [formatter stringFromDate:contro.date];
     [self.currentBtn setTitle:self.dateString forState:UIControlStateNormal];
   
}
-(void)selectToday:(id)sender
{
    NSDate *senddate=[NSDate date];
    NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"YYYY-MM-dd"];
    self.dateString = [dateformatter stringFromDate:senddate];
     [self.currentBtn setTitle:self.dateString forState:UIControlStateNormal];
    [self.popCon dismissPopoverAnimated:YES];
}
-(void)selectClearDate:(id)sender
{
     [self.currentBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [self.popCon dismissPopoverAnimated:YES];
}
-(void)createLabelWithTitle:(NSString *)title fontSize:(int)fontSize frame:(CGRect)frame{
    UILabel *lbl = [[UILabel alloc]initWithFrame:frame];
    lbl.text = title;
    lbl.backgroundColor = [UIColor clearColor];
    lbl.textColor = [UIColor grayColor];
    lbl.font = [UIFont fontWithName:@"ArialMT" size:fontSize];
    [self.serviceScrollView addSubview:lbl];
}

-(UITextField *)setupTextFieldWithFrame:(CGRect)frame{
    UITextField *txt = [[UITextField alloc]initWithFrame:frame];
    txt.borderStyle = UITextBorderStyleLine;
    txt.textColor = [UIColor grayColor];
    txt.font = [UIFont fontWithName:@"ArialMT" size:15];
    [txt setTextAlignment:NSTextAlignmentCenter];
    txt.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.serviceScrollView addSubview:txt];
    return txt;
}

-(void)setupDropdownLabelWithFrame:(CGRect)frame{
    UILabel *label1 = [[UILabel alloc]initWithFrame:frame];
    [label1 setBackgroundColor:[UIColor clearColor]];
    label1.layer.borderColor = [[UIColor blackColor]CGColor];
    label1.layer.borderWidth = 1;
    [self.serviceScrollView addSubview:label1];
}

-(UIButton *)setupDropdownButtonWithFrame:(CGRect)frame action:(SEL)method
{
    UIButton *btn = [[UIButton alloc]initWithFrame:frame];
    [btn setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [btn addTarget:self action:method forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:@"< 空 >" forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.serviceScrollView addSubview:btn];
    return btn;
}

-(void)settlementbutton2:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender = sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:222 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.gongdanzhuangtaiBtn.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(120, 15, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSArray *zidianArr=[self readershuDICimform][@"TM_RO_STATUS"];
    NSMutableArray *modelArr = [[NSMutableArray alloc]init];
    [gongdanzhuangtaiIDArr removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [modelArr addObject:dic[@"NAME"]];
        [gongdanzhuangtaiIDArr addObject:dic[@"CODE"]];
    }
    [modelArr insertObject:@"< 空 >" atIndex:0];
    contentCon.list = modelArr;
    
    [contentCon.myTableView reloadData];
}

-(void)settlementbutton3:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.jiedaiyuanBtn.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(120, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    
    NSArray *zidianArr=[self readershuDICimform][@"SERVICE_ADVISOR"];
    NSMutableArray *modelArr = [[NSMutableArray alloc]init];
    [jiedaiguwenIDArr removeAllObjects];
    
    for(NSDictionary *dic in zidianArr)
    {
        [modelArr addObject:dic[@"NAME"]];
        [jiedaiguwenIDArr addObject:dic[@"CODE"]];
    }
    [modelArr insertObject:@"< 空 >" atIndex:0];
    contentCon.list = modelArr;
    
    [contentCon.myTableView reloadData];
}

- (void)selectDelegate:(NSInteger)row btn:(UIButton*)btn
{
    if (row>0) {
        if (btn==self.jiedaiyuanBtn) {
            selectJiedaiyuanID = [jiedaiguwenIDArr objectAtIndex:row-1];
                NSLog(@"---%@---",selectJiedaiyuanID);
        }
        else if (btn==self.gongdanzhuangtaiBtn){
            selectGongdanzhuangtaiID = [gongdanzhuangtaiIDArr objectAtIndex:row-1];
           NSLog(@"---%@---",selectGongdanzhuangtaiID);
        }
    }else{
        selectJiedaiyuanID = @"";
        selectGongdanzhuangtaiID = @"";
        
    }
    
   
    
    [self.popCon dismissPopoverAnimated:YES];
    self.popCon = nil;
}

#pragma mark - 查询按钮的回调方法
-(void)query:(id)sender
{

    [self.listRowCollection removeAllObjects];
    
    [self firastRequest];
    
}

#pragma mark - 各种需要调用的按钮
-(void)loadCallButtonPicture
{
    self.chooseTableButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.chooseTableButton1 setFrame:CGRectMake(75, 390, 25, 25)];
    [self.chooseTableButton1 setImage:[UIImage imageNamed:@"ht已选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton1 addTarget:self action:@selector(chooseTableButton1:) forControlEvents:UIControlEventTouchUpInside];
    [self.serviceScrollView addSubview:self.chooseTableButton1];
    
    self.chooseTableButton2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.chooseTableButton2 setFrame:CGRectMake(210, 390, 25, 25)];
    [self.chooseTableButton2 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton2 addTarget:self action:@selector(chooseTableButton2:) forControlEvents:UIControlEventTouchUpInside];
    [self.serviceScrollView addSubview:self.chooseTableButton2];
    
    self.chooseTableButton3 = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.chooseTableButton3 setFrame:CGRectMake(360, 390, 25, 25)];
    [self.chooseTableButton3 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton3 addTarget:self action:@selector(chooseTableButton3:) forControlEvents:UIControlEventTouchUpInside];
    [self.serviceScrollView addSubview:self.chooseTableButton3];
    
    self.paigongButton = [[UIButton alloc]initWithFrame:CGRectMake(880, 393, 75, 34)];
    [self.paigongButton setTitle:@"派 工" forState:UIControlStateNormal];
    [self.paigongButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.paigongButton setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.paigongButton addTarget:self action:@selector(paigongButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.paigongButton setHidden:NO];
    [self.serviceScrollView addSubview:self.paigongButton];
    
    //选择时间查看工位信息
    NSDate *senddate=[NSDate date];
    NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"YYYY-MM-dd"];
    timeStr = [dateformatter stringFromDate:senddate];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(610, 395, 140, 30)];
    [label setBackgroundColor:[UIColor whiteColor]];
    label.layer.borderColor = [[UIColor grayColor]CGColor];
    label.layer.borderWidth = 0.8;
    [self.serviceScrollView addSubview:label];
    self.timeQuery = [[UIButton alloc]initWithFrame:CGRectMake(611, 396, 138, 28)];
    [self.timeQuery setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.timeQuery addTarget:self action:@selector(timeQuery:) forControlEvents:UIControlEventTouchUpInside];
    [self.timeQuery setTitle:timeStr forState:UIControlStateNormal];
    self.timeQuery.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.timeQuery setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.serviceScrollView addSubview:self.timeQuery];
    
    self.chakanBtn = [[UIButton alloc]initWithFrame:CGRectMake(765, 393, 75, 34)];
    [self.chakanBtn setTitle:@"查 看" forState:UIControlStateNormal];
    [self.chakanBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.chakanBtn setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
//    self.chakanBtn.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:23];
    [self.chakanBtn addTarget:self action:@selector(chakanBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.serviceScrollView addSubview:self.chakanBtn];
}
-(void)chakanBtn:(id)sender
{
    self.timeLine = @"好好的";
    if([self.timeQuery.titleLabel.text isEqualToString:timeStr])
    {
//        [self.transverseScrollView addSubview:self.timeLineView];
        [self.timeLineView setHidden:NO];
    }
    else
    {
        [self.timeLineView setHidden:YES];
    }
    [SVProgressHUD showWithStatus:@"请等待...."];
    
    if([self.timeQuery.titleLabel.text isEqualToString:@"请选择"])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择要查看日期！" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else
    {
        self.credentials = @"010";
        if(_ShaBiZhaoShaoFeiOne == YES)
        {
            [self chooseTableButton1:self.chooseTableButton1];
        }
        if(_ShaBiZhaoShaoFeiTow == YES)
        {
            [self chooseTableButton2:self.chooseTableButton2];
        }
        if(_ShaBiZhaoShaoFeiTheer == YES)
        {
            [self chooseTableButton3:self.chooseTableButton3];
        }
    }
    [SVProgressHUD dismiss];
}
-(void)timeQuery:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 10, 40) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged:(id)sender{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    self.dateString = [formatter stringFromDate:contro.date];
    [self.timeQuery setTitle:self.dateString forState:UIControlStateNormal];
}
#pragma mark - 派工按钮的回调
-(void)paigongButton:(id)sender
{
    if(_jobSheetId == nil)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择维修单号！" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else
    {
        self.serviceCompileViewController = nil;
        self.serviceCompileViewController = [[ServiceCompileViewController alloc]initWithNibName:@"ServiceCompileViewController" bundle:nil];
        self.serviceCompileViewController.delegate = self;
        self.serviceCompileViewController.receiveDit = _naoguoqu;
        [self presentPopupViewController:self.serviceCompileViewController animationType:MJPopupViewAnimationFade];
        
//        NSLog(@"__ __ _ __ _ ___%@",self.serviceCompileViewController.receiveDit);
    }
}

-(void)paigongBtnJumpedByServiceUIPressed
{
    _naoguoqu = [NSMutableDictionary dictionaryWithDictionary:self.dicDataJumpByServiceUI];
    
    if (nil == _naoguoqu)
    {
        return;
    }
    self.serviceCompileViewController = nil;
    self.serviceCompileViewController = [[ServiceCompileViewController alloc]initWithNibName:@"ServiceCompileViewController" bundle:nil];
    self.serviceCompileViewController.delegate = self;
    self.serviceCompileViewController.receiveDit = _naoguoqu;
    [self presentPopupViewController:self.serviceCompileViewController animationType:MJPopupViewAnimationFade];
}

//关闭弹出窗的代理方法
- (void)cancelButtonClicked:(ServiceCompileViewController *)aSecondDetailViewController
{
    [self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade];
}
#pragma mark - 机修视图选择的回调
-(void)chooseTableButton1:(id)sender
{
    for(UIView *view in self.jiXiuBackground.subviews)
    {
        [view removeFromSuperview];
    }
    [self chooseJixiu];
    [_jiXiuBackground setHidden:NO];
    [_banJinBackground setHidden:YES];
    [_penQiBackground setHidden:YES];
    
    _weiXiutype = @"0";
    webService *webcon = [[webService alloc] init];    //工位
    webcon.methodName = GETWORKSTATIONLIST;
    NSMutableArray *gWeiArry = [NSMutableArray arrayWithObjects:@"workshopType",_weiXiutype,nil];
    [webcon commonGetSharedRequest:GETWORKSTATIONLIST wsparas:gWeiArry];
    
    webService *web = [[webService alloc]init];
    web.methodName = GETDISPATCHINGVIEWLIST;
    NSMutableArray *arry = [NSMutableArray arrayWithObjects:@"viewType",_weiXiutype,nil];
    [web commonGetSharedRequest:GETDISPATCHINGVIEWLIST wsparas:arry];
}
#pragma mark - 钣金视图选择的回调
-(void)chooseTableButton2:(id)sender
{
    for(UIView *view in self.banJinBackground.subviews)
    {
        [view removeFromSuperview];
    }
    [self chooseBanjin];
    [_banJinBackground setHidden:NO];
    [_jiXiuBackground setHidden:YES];
    [_penQiBackground setHidden:YES];
    
    
    _weiXiutype = @"1";
    webService *webcon = [[webService alloc] init];    //工位
    webcon.methodName = GETWORKSTATIONLIST;
    NSMutableArray *gWeiArry = [NSMutableArray arrayWithObjects:@"workshopType",_weiXiutype,nil];
    [webcon commonGetSharedRequest:GETWORKSTATIONLIST wsparas:gWeiArry];

    webService *web = [[webService alloc]init];
    web.methodName = GETDISPATCHINGVIEWLIST;
    NSMutableArray *arry = [NSMutableArray arrayWithObjects:@"viewType",_weiXiutype,nil];
    [web commonGetSharedRequest:GETDISPATCHINGVIEWLIST wsparas:arry];
    
}
#pragma mark - 喷漆视图选择的回调
-(void)chooseTableButton3:(id)sender
{
    for(UIView *view in self.penQiBackground.subviews)
    {
        [view removeFromSuperview];
    }
    [self choosePenqi];
    [_penQiBackground setHidden:NO];
    [_jiXiuBackground setHidden:YES];
    [_banJinBackground setHidden:YES];
    
    _weiXiutype = @"2";
    webService *webcon = [[webService alloc] init];    //工位
    webcon.methodName = GETWORKSTATIONLIST;
    NSMutableArray *gWeiArry = [NSMutableArray arrayWithObjects:@"workshopType",_weiXiutype,nil];
    [webcon commonGetSharedRequest:GETWORKSTATIONLIST wsparas:gWeiArry];
    
    webService *web = [[webService alloc]init];
    web.methodName = GETDISPATCHINGVIEWLIST;
    NSMutableArray *arry = [NSMutableArray arrayWithObjects:@"viewType",_weiXiutype,nil];
    [web commonGetSharedRequest:GETDISPATCHINGVIEWLIST wsparas:arry];
}
//工位
-(void)getworkStationList:(NSNotification*)notification
{
    self.workStationDit = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.workStationArray = [self.workStationDit objectForKey:@"workStationList"];
    //添加工位之前先移除里面的内容
    for (UIView * view in [self.workBackView subviews])
    {
        [view removeFromSuperview];
    }
    [self loadWorkStationSZ];
//    NSLog(@"我擦擦擦擦:%@",self.workStationLabelArray);
}
-(void)loadWorkStationSZ
{
    self.workStationLabelArray = [[self.workStationDit valueForKey:@"workStationList"]valueForKey:@"workStationName"];
    self.workStationIsPaig = [[self.workStationDit valueForKey:@"workStationList"]valueForKey:@"workStationId"];//6-12
//    NSLog(@"^.^^.^.^.^.^.^.^.^.^.%@",self.workStationIsPaig);
    for(int i = 0; i < [self.workStationLabelArray count];i++)
    {
        self.workStationNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, (5+i*45), 95, 45)];
        [self.workStationNameLabel setBackgroundColor:[UIColor clearColor]];
        self.workStationNameLabel.text = [self.workStationLabelArray objectAtIndex:i];
        self.workStationNameLabel.textColor = [UIColor grayColor];
        self.workStationNameLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
        [self.workBackView addSubview:self.workStationNameLabel];
    }
    //根据工位的长度设置ScrollView和背景层的view
    self.workBackView.frame = CGRectMake(60, 480, 100,[self.workStationLabelArray count]*45);
    self.serviceScrollView.contentSize = CGSizeMake(1024,600+[self.workStationLabelArray count]*45);
    [self.transverseScrollView setFrame:CGRectMake(150, 450, 820, 45+[self.workStationLabelArray count]*45)];
    [self.TimeZoneTableView setFrame:CGRectMake(0, 30, 1600,[self.workStationLabelArray count]*45)];
    if([_weiXiutype isEqualToString:@"0"])
    {
        [self.jiXiuBackground setFrame:CGRectMake(0, 30, 1600, [self.workStationLabelArray count]*45)];
    }
    if([_weiXiutype isEqualToString:@"0"])
    {
        [self.banJinBackground setFrame:CGRectMake(0, 30, 1600, [self.workStationLabelArray count]*45)];
    }
    if([_weiXiutype isEqualToString:@"0"])
    {
        [self.penQiBackground setFrame:CGRectMake(0, 30, 1600, [self.workStationLabelArray count]*45)];
    }
    [self.TimeZoneTableView reloadData];
    
    [self.timeTiaoLabel setFrame:CGRectMake(beging, 1, 2, [self.workStationLabelArray count]*45)];
}

-(void)getDispatchingViewList:(NSNotification*)notification//派工分类查询
{
//    NSLog(@"**********************************************************************************************************1");
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
//    NSLog(@"分类查询json：%@",theJson);

    if([self.credentials isEqualToString:@"010"])
    {   //当天开始时间
        NSString *str = self.timeQuery.titleLabel.text;
        NSString *miao = @" 00:01";
        NSString *shijian = [NSString stringWithFormat:@"%@%@",str,miao];
        NSDateFormatter *ain =[[NSDateFormatter alloc]init];
        [ain setDateFormat:@"YYYY-MM-dd HH:mm"];
        NSDate *date = [ain dateFromString:shijian];
        NSTimeZone *zone = [NSTimeZone defaultTimeZone];//获得当前应用程序默认的时区
        NSInteger interval = [zone secondsFromGMTForDate:[NSDate date]];//以秒为单位返回当前应用程序与世界标准时间（格林威尼时间）的时差
        NSDate *localeDate = [date dateByAddingTimeInterval:interval];
        NSTimeInterval timeInterval = [localeDate timeIntervalSince1970];
        _dayBegin = [[NSNumber alloc]init];
        _dayBegin = [NSNumber numberWithFloat:timeInterval];
        //当天结束时间
        NSString *stu = self.timeQuery.titleLabel.text;
        NSString *pinjie = @" 23:59";
        NSString *shijian2 = [NSString stringWithFormat:@"%@%@",stu,pinjie];
        NSDateFormatter *bin =[[NSDateFormatter alloc]init];
        [bin setDateFormat:@"YYYY-MM-dd HH:mm"];
        NSDate *date1 = [bin dateFromString:shijian2];
        NSTimeZone *zone1 = [NSTimeZone defaultTimeZone];//获得当前应用程序默认的时区
        NSInteger interval1 = [zone1 secondsFromGMTForDate:[NSDate date]];//以秒为单位返回当前应用程序与世界标准时间（格林威尼时间）的时差
        NSDate *localeDate1 = [date1 dateByAddingTimeInterval:interval1];
        NSTimeInterval timeInterval1 = [localeDate1 timeIntervalSince1970];
        _dayend = [[NSNumber alloc]init];
        _dayend = [NSNumber numberWithFloat:timeInterval1];
        
        NSLog(@"str：%@",str);
        NSLog(@"stu：%@",stu);

        NSLog(@"开始：%@",_dayBegin);
        NSLog(@"结束：%@",_dayend);
    }
    else
    {
        //获取当天的起始时间
        NSDate *senddate=[NSDate date];
        NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
        [dateformatter setDateFormat:@"YYYY-MM-dd"];
        NSString *str = [dateformatter stringFromDate:senddate];
        NSString *miao = @" 00:01";
        NSString *shijian = [NSString stringWithFormat:@"%@%@",str,miao];
        NSDateFormatter *ain =[[NSDateFormatter alloc]init];
        [ain setDateFormat:@"YYYY-MM-dd HH:mm"];
        NSDate *date = [ain dateFromString:shijian];
        NSTimeZone *zone = [NSTimeZone defaultTimeZone];//获得当前应用程序默认的时区
        NSInteger interval = [zone secondsFromGMTForDate:[NSDate date]];//以秒为单位返回当前应用程序与世界标准时间（格林威尼时间）的时差
        NSDate *localeDate = [date dateByAddingTimeInterval:interval];
        NSTimeInterval timeInterval = [localeDate timeIntervalSince1970];
        //    NSLog(@"时间转换成秒：%f",timeInterval);
        _dayBegin = [[NSNumber alloc]init];
        _dayBegin = [NSNumber numberWithFloat:timeInterval];
        
        //获取当天的结束时间
        NSDate *end = [NSDate date];
        NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
        [formatter setDateFormat:@"YYYY-MM-dd"];
        NSString *stu = [formatter stringFromDate:end];
        NSString *pinjie = @" 23:59";
        NSString *shijian2 = [NSString stringWithFormat:@"%@%@",stu,pinjie];
        NSDateFormatter *bin =[[NSDateFormatter alloc]init];
        [bin setDateFormat:@"YYYY-MM-dd HH:mm"];
        NSDate *date1 = [bin dateFromString:shijian2];
        NSTimeZone *zone1 = [NSTimeZone defaultTimeZone];//获得当前应用程序默认的时区
        NSInteger interval1 = [zone1 secondsFromGMTForDate:[NSDate date]];//以秒为单位返回当前应用程序与世界标准时间（格林威尼时间）的时差
        NSDate *localeDate1 = [date1 dateByAddingTimeInterval:interval1];
        NSTimeInterval timeInterval1 = [localeDate1 timeIntervalSince1970];
        //    NSLog(@"当天结束时间转成秒：%f",timeInterval1);
        _dayend = [[NSNumber alloc]init];
        _dayend = [NSNumber numberWithFloat:timeInterval1];
        
        NSLog(@"傻逼赵少飞1：%@",str);
        NSLog(@"傻逼赵少飞1：%@",stu);
        
        NSLog(@"开始傻逼赵少飞1：%@",_dayBegin);
        NSLog(@"结束傻逼赵少飞1：%@",_dayend);
    }

    self.listDisArray = [theJson valueForKey:@"dispatchingList"];

    for(int i = 0;i<[self.listDisArray count];i++)
    {
        //取出派工开始时间和结束时间转化成float型
        self.paigongkaishi = [[self.listDisArray objectAtIndex:i]valueForKey:@"estimatedStartTime"];
//        NSLog(@"$$$$$$派工开始时间：%@",self.paigongkaishi);
        //从数组里取出工位的id（数组在loadWorkStationSZ方法里，6-12）
        NSString *workStationId = [[self.listDisArray objectAtIndex:i]valueForKey:@"workStationId"];
//        NSLog(@"^.^%@",workStationId);
        //取出接待员和车牌号
        NSString *chePai = [[self.listDisArray objectAtIndex:i]valueForKey:@"plateNumber"];
        NSString *jieDai = [[self.listDisArray objectAtIndex:i]valueForKey:@"evaluatorName"];
        NSDateFormatter *bin =[[NSDateFormatter alloc]init];
        [bin setDateFormat:@"YYYY-MM-dd HH:mm"];
        NSDate *date1 = [bin dateFromString:self.paigongkaishi];
        NSTimeZone *zone1 = [NSTimeZone defaultTimeZone];
        NSInteger interval1 = [zone1 secondsFromGMTForDate:[NSDate date]];
        NSDate *localeDate1 = [date1 dateByAddingTimeInterval:interval1];
        NSTimeInterval timeInterval1 = [localeDate1 timeIntervalSince1970];
//        NSLog(@"%f",timeInterval1);
        //结束时间
        self.paigongjieshu = [[self.listDisArray objectAtIndex:i]valueForKey:@"estimatedEndTime"];
//        NSLog(@"$$$$$$派工结束时间：%@",self.paigongjieshu);
        NSDateFormatter *ain =[[NSDateFormatter alloc]init];
        [ain setDateFormat:@"YYYY-MM-dd HH:mm"];
        NSDate *date = [ain dateFromString:self.paigongjieshu];
        NSTimeZone *zone = [NSTimeZone defaultTimeZone];
        NSInteger interval = [zone secondsFromGMTForDate:[NSDate date]];
        NSDate *localeDate = [date dateByAddingTimeInterval:interval];
        NSTimeInterval timeInterval2 = [localeDate timeIntervalSince1970];
//        NSLog(@"%f",timeInterval2);

        float toDayBegin = [_dayBegin floatValue];
//        NSLog(@"!!!!!!%f",toDayBegin);
        float toDayEnd = [_dayend floatValue];
//        NSLog(@"!*!*!*!*!*!%f",toDayEnd);
        //如果派工开始时间小于当天开始时间并且派工结束时间小于当天结束时间
        if(timeInterval1 < toDayBegin && timeInterval2 < toDayEnd && timeInterval2 > toDayBegin)
        {
                    //取出结束时间转换成像素坐标
                    NSString *hours = [self.paigongjieshu substringWithRange:NSMakeRange(11, 3)];
                    NSString *minutes = [self.paigongjieshu substringWithRange:NSMakeRange(14, 2)];
                    float floathours = [hours floatValue];
                    float floatminutes = [minutes floatValue];
                    float huiZhiEnd = (floathours*60+floatminutes)*1.1;
//                    NSLog(@"^^^^^^^!!!&&&!!%f",huiZhiEnd);
            //根据取出的工位id判断它在工位id数组里对应的下标
            NSString *strOn = [NSString stringWithFormat:@"%d",[self.workStationIsPaig indexOfObject:workStationId]];
//            NSLog(@"___!____!____!**%@",strOn);
            int intStrOn = [strOn intValue];
            //根据切换视图接口所传的参数判断添加在哪个层上
            self.paigongKuaiView = [[PaigongKuaiView alloc]initWithFrame:CGRectMake(0, intStrOn*45, huiZhiEnd, 45)];
            self.paigongKuaiView.chePai.text = chePai;
            self.paigongKuaiView.jieDaiYuan.text = jieDai;
            [self panDuan];
        }
        //如果派工开始时间大于当天开始时间并且派工结束时间小于当天结束时间（在今天范围内绘制）
        if(timeInterval1 > toDayBegin && timeInterval2 < toDayEnd)
        {
//            NSLog(@"**********************************************************************************************************2");
                //取出派工开始时间和结束时间转换成像素坐标
                NSString *hours1 = [self.paigongkaishi substringWithRange:NSMakeRange(11, 3)];
                NSString *minutes1 = [self.paigongkaishi substringWithRange:NSMakeRange(14, 2)];
                float floathours1 = [hours1 floatValue];
                float floatminutes1 = [minutes1 floatValue];
                float huiZhiBegin = (floathours1*60+floatminutes1)*1.1;
                NSString *hours2 = [self.paigongjieshu substringWithRange:NSMakeRange(11, 3)];
                NSString *minutes2 = [self.paigongjieshu substringWithRange:NSMakeRange(14, 2)];
                float floathours2 = [hours2 floatValue];
                float floatminutes2 = [minutes2 floatValue];
                float huiZhiEnd = (floathours2*60+floatminutes2)*1.1;
            
            NSString *strOn = [NSString stringWithFormat:@"%d",[self.workStationIsPaig indexOfObject:workStationId]];
//            NSLog(@"___!____!____!**%@",strOn);
            int intStrOn = [strOn intValue];
            
                //根据切换视图接口所传的参数判断添加在哪个层上
            self.paigongKuaiView = [[PaigongKuaiView alloc]initWithFrame:CGRectMake(huiZhiBegin, intStrOn*45, huiZhiEnd-huiZhiBegin, 45)];
            self.paigongKuaiView.chePai.text = chePai;
            self.paigongKuaiView.jieDaiYuan.text = jieDai;
            [self panDuan];
            
        }
        //如果派工开始时间大于当天开始时间并且派工结束时间大于当天结束时间
        if(timeInterval1 > toDayBegin && timeInterval2 > toDayEnd)
        {
//            NSLog(@"**********************************************************************************************************3");


                //取出派工开始时间和结束时间转换成像素坐标
                NSString *hours1 = [self.paigongkaishi substringWithRange:NSMakeRange(11, 3)];
                NSString *minutes1 = [self.paigongkaishi substringWithRange:NSMakeRange(14, 2)];
                float floathours1 = [hours1 floatValue];
                float floatminutes1 = [minutes1 floatValue];
                float huiZhiBegin = (floathours1*60+floatminutes1)*1.1;

            NSString *strOn = [NSString stringWithFormat:@"%d",[self.workStationIsPaig indexOfObject:workStationId]];
//            NSLog(@"___!____!____!**%@",strOn);
            int intStrOn = [strOn intValue];
            
                //根据切换视图接口所传的参数判断添加在哪个层上
            self.paigongKuaiView = [[PaigongKuaiView alloc]initWithFrame:CGRectMake(huiZhiBegin, intStrOn*45, 1600-huiZhiBegin, 45)];
            self.paigongKuaiView.chePai.text = chePai;
            self.paigongKuaiView.jieDaiYuan.text = jieDai;
            [self panDuan];
        }
        //如果派工开始时间小于当天开始时间并且派工结束时间大于当天结束时间
        if(timeInterval1 < toDayBegin && timeInterval2 > toDayEnd)
        {
//            NSLog(@"**********************************************************************************************************4");

            NSString *strOn = [NSString stringWithFormat:@"%d",[self.workStationIsPaig indexOfObject:workStationId]];
//            NSLog(@"___!____!____!**%@",strOn);
            int intStrOn = [strOn intValue];
            
                //根据切换视图接口所传的参数判断添加在哪个层上
            self.paigongKuaiView = [[PaigongKuaiView alloc]initWithFrame:CGRectMake(0, intStrOn*45, 1600, 45)];
            self.paigongKuaiView.chePai.text = chePai;
            self.paigongKuaiView.jieDaiYuan.text = jieDai;
            [self panDuan];
        }
        if(timeInterval1 < toDayBegin && timeInterval2 < toDayBegin)
        {
            
        }
    }
}

#pragma mark - 返回主页面的回调
-(void)homeButton:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
    [self removeObserver];
    [self removeNotification];
}
#pragma mark - tableView的各种方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(tableView == self.ServiceTableView)
    {
        return [self.listRowCollection count];
    }
    else if(tableView == self.TimeZoneTableView)
    {
        return [self.workStationLabelArray count];
    }

    return 0;
}
#pragma mark - 弹出窗口
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (tableView==self.ServiceTableView) {
        HJWorkOrderlistModel*workOrderlistModel=self.workOrderlistAry[indexPath.row];
         NSDictionary *param = @{@"RO_NO":workOrderlistModel.RO_NO,@"VIN":workOrderlistModel.VIN};
        MainMenuDataModel *mainModel = [MainMenuDataModel sharedMainMenuDataModel];
        [SVProgressHUD showWithStatus:@"正在查询"];
        [MyAFNetWorkManager postWithParam:param andAction:@"QUERY_REPAIR_ORDER_DETAIL_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
            [SVProgressHUD dismiss];
            if (error) {
                [SVProgressHUD showErrorWithStatus:@"获取数据失败"];
                return;
            }else{
                getJobSheetViewController *getJobSheetCon = [[getJobSheetViewController alloc] initWithNibName:@"getJobSheetViewController" bundle:nil];
                HJRepairOrderInfoModel*repairOrderInfoModel=[HJRepairOrderInfoModel mj_objectWithKeyValues:obj];
                getJobSheetCon.repairOrderInfoModel=repairOrderInfoModel;
                NSMutableArray *arr = obj[@"TM_VEHICLE"];//预交款
                NSDictionary *predic = arr[0];
                NSMutableDictionary *baseInfo = obj[@"TT_REPAIR_ORDER"][0];
                if (predic[@"PRE_PAY"]) {
                    [baseInfo setObject:predic[@"PRE_PAY"] forKey:@"PRE_PAY"];
                }
                id curMileage = predic[@"CURRENT_MILEAGE"];
                [baseInfo setObject:curMileage?curMileage:@"0" forKey:@"CURRENT_MILEAGE"];
                mainModel.dicBaseMessage = baseInfo;//基本信息
                mainModel.arrOutCheck = obj[@"TT_DEFECT"];//缺陷
                mainModel.repairProjects = obj[@"TT_RO_LABOUR"];//维修项目
                mainModel.partList = obj[@"TT_RO_REPAIR_PART"];//零件
                mainModel.attachProjects = obj[@"TT_RO_ADD_ITEM"];//附加项目
                mainModel.arrCarryGoods = obj[@"TT_RO_CONFIRM"];//物品确认
                mainModel.arrImageList = obj[@"TT_RO_FILE"];//图片列表
                getJobSheetCon.optType = operationTypeModify;
            mainModel.deletedRepairProjects = nil;
            mainModel.deletedPartList = nil;
            mainModel.deletedAttachProjects = nil;
            mainModel.arrOutCheckDeleted = nil;
            mainModel.nRowForRepairItemList = -1;
            mainModel.nRowForPartList = -1;
            mainModel.nRowForOtherChargeList = -1;
            mm_picRecodeDataModel *picDataModel = [mm_picRecodeDataModel sharedModelIns];
            picDataModel.arrForNewImage = nil;
            [self.navigationController pushViewController:getJobSheetCon animated:YES];
            }
        }];
    }
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    if(tableView == self.ServiceTableView)
    {
        static NSString *indetfire = @"cell";
       ServiceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indetfire];
        if(nil == cell)
        {
            cell = [[ServiceTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
            tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        }
        
        NSDictionary *dic = [self.listRowCollection objectAtIndex:row];
        if(row < [self.listRowCollection count])
        {
            //[self cellLabelDeta];
            cell.cellLabelOne.text = [[self.listRowCollection objectAtIndex:row] objectForKey:@"RO_NO"];
            cell.cellLabelTwo.text = [[self.listRowCollection objectAtIndex:row] objectForKey:@"LICENSE"];
            cell.cellLabelThree.text = [self transSting:[dic objectForKey:@"REWORK_COUNT"]];
            
            cell.cellLabelFour.text = [self getGongdanzhuangtai:[self transSting:[dic objectForKey:@"RO_DETAIL_STATUS"]]];
            cell.cellLabelFive.text =[dic objectForKey:@"NAME"];
//            [self getWeixiuleixing:[self transSting:[dic objectForKey:@"NAME"]]];
            cell.cellLabelSix.text = [self getJiedaiyuan:[dic objectForKey:@"SERVICE_ADVISOR"]];
            
            cell.cellLabelSeven.text = [dic objectForKey:@"VIN"];
            cell.cellLabelEight.text = [dic objectForKey:@"ESTIMATE_END_TIME"];
            cell.cellLabelNine.text = [dic objectForKey:@"END_TIME_SUPPOSED"];
        }
        return cell;
    }
    else if(tableView == self.TimeZoneTableView)
    {
        static NSString *indetfire = @"cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indetfire];
        if(nil == cell)
        {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
            tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        }

        return cell;
    }
    
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView == self.ServiceTableView)
    {
        return 45;
    }
    else if(tableView == self.TimeZoneTableView)
    {
        return 45;
    }
    return 0;
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row%2 == 1)
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:226.00/255 green:226.00/255 blue:226.00/255 alpha:1];
    }
    else
    {
        cell.backgroundColor = [UIColor whiteColor];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
}

- (NSString *)transSting:(id)obj
{
    if ([obj isKindOfClass:[NSNumber class]]) {
        NSNumber *newObj = (NSNumber *)obj;
        return newObj.stringValue;
    }
    
    return obj;
}

- (NSString *)getJiedaiyuan:(NSString *)code
{
    NSArray *zidianArr=[self readershuDICimform][@"SERVICE_ADVISOR"];
    for (NSDictionary *dic in zidianArr) {
        if ([dic[@"CODE"] isEqualToString:code]) {
            
            return dic[@"NAME"];
        }
    }
    
    return nil;
}

- (NSString *)getWeixiuleixing:(NSString *)code
{
    NSArray *zidianArr=[self readershuDICimform][@"TM_RO_TYPE"];
    for (NSDictionary *dic in zidianArr) {
        if ([dic[@"CODE"] isEqualToString:code]) {
            
            return dic[@"NAME"];
        }
    }
    
    
    return nil;
}

- (NSString *)getGongdanzhuangtai:(NSString *)code
{
    NSArray *zidianArr=[self readershuDICimform][@"TM_RO_STATUS"];
    for (NSDictionary *dic in zidianArr) {
        if ([dic[@"CODE"] isEqualToString:code]) {
            
            return dic[@"NAME"];
        }
    }
    return nil;
}

-(NSMutableDictionary *)readershuDICimform
{
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path=[paths objectAtIndex:0];
    NSString *str=[path stringByAppendingPathComponent:@"Dic.text"];
    dic=[NSMutableDictionary dictionaryWithContentsOfFile:str];
    //nslog(@"%@",dic);
    return dic;
}

#pragma mark - 界面固定label标题
-(void)loadSecondPartPicture
{
    UILabel *fixed1 = [[UILabel alloc]initWithFrame:CGRectMake(110, 390, 90, 35)];
    fixed1.text = @"机修视图";
    fixed1.backgroundColor = [UIColor clearColor];
    fixed1.textColor = [UIColor grayColor];
    fixed1.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.serviceScrollView addSubview:fixed1];
    
    UILabel *fixed2 = [[UILabel alloc]initWithFrame:CGRectMake(250, 390, 90, 35)];
    fixed2.text = @"钣金视图";
    fixed2.backgroundColor = [UIColor clearColor];
    fixed2.textColor = [UIColor grayColor];
    fixed2.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.serviceScrollView addSubview:fixed2];
    
    UILabel *fixed3 = [[UILabel alloc]initWithFrame:CGRectMake(400, 390, 90, 35)];
    fixed3.text = @"喷漆视图";
    fixed3.backgroundColor = [UIColor clearColor];
    fixed3.textColor = [UIColor grayColor];
    fixed3.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.serviceScrollView addSubview:fixed3];
    
    UILabel *fixed4 = [[UILabel alloc]initWithFrame:CGRectMake(530, 395, 80, 35)];
    fixed4.text = @"派工日期:";
    fixed4.backgroundColor = [UIColor clearColor];
    fixed4.textColor = [UIColor grayColor];
    fixed4.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.serviceScrollView addSubview:fixed4];
}
-(void)loadNewTitleLabelPicture
{
    NSMutableArray *labelMutabelArray = [[NSMutableArray alloc]initWithObjects:@"维修单号",@"车牌",@"工单状态",@"维修分类",@"服务专员",@"预计完工时间",@"预计交车时间", nil];
    CGFloat W=self.ServiceTableView.bounds.size.width/labelMutabelArray.count;
    for(int i = 0; i <labelMutabelArray.count;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(self.ServiceTableView.frame.origin.x+i*W, 265, W, 45)];
        [titlelabel setBackgroundColor:[[UIColor alloc]initWithRed:0.96 green:0.96 blue:0.96 alpha:1]];
        titlelabel.text = [labelMutabelArray objectAtIndex:i];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.layer.borderColor = [[UIColor grayColor]CGColor];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:16];
        titlelabel.textAlignment=NSTextAlignmentCenter;
        [self.serviceScrollView addSubview:titlelabel];
    }
}

#pragma mark - add派工图标
-(void)adddispatching
{
    _panDuanGchang = [self.passDictionary valueForKey:@"factoryName"];//取出工场key对应的数据
    //派工图标放置的坐标点
    float startingPoint = [self.startingPoint floatValue];
    float viewWide = [self.endPoint floatValue]-[self.startingPoint floatValue];
    
    NSString *panGgongwei = [self.passDictionary valueForKey:@"row"];//取出所选工位对应的行号
    int intpanGgongwei = [panGgongwei intValue];
    
//    NSLog(@"!_!_!_!_!_!_!_!_!_!_!%@",[self.passDictionary valueForKey:@"plateNumber"]);
//    NSLog(@"!_!_!_$!_!_!_!$_!_!_!_!%@",[self.passDictionary valueForKey:@"evaluatorName"]);

//    self.paigongKuaiView = [[PaigongKuaiView alloc]initWithFrame:CGRectMake(startingPoint, intpanGgongwei*45, viewWide, 45)];
    [self.paigongKuaiView setFrame:CGRectMake(startingPoint, intpanGgongwei*45, viewWide, 45)];
    self.paigongKuaiView.chePai.text = [self.passDictionary valueForKey:@"plateNumber"];
    self.paigongKuaiView.jieDaiYuan.text = [self.passDictionary valueForKey:@"evaluatorName"];
    self.paigongKuaiView.backgroundColor = [UIColor whiteColor];
    //根据传过来的工场字符串判断把派工层添加在哪个视图上
    if([_panDuanGchang isEqualToString:@"修理工场"])
    {
        [_jiXiuBackground addSubview:self.paigongKuaiView];
        [self chooseJixiu];
        [_jiXiuBackground setHidden:NO]; //根据取出的字段让对应的层显示，隐藏其他层
        [_banJinBackground setHidden:YES];
        [_penQiBackground setHidden:YES];
    }
    else if([_panDuanGchang isEqualToString:@"钣金工场"])
    {
        [_banJinBackground addSubview:self.paigongKuaiView];
        [self chooseBanjin];
        [_banJinBackground setHidden:NO]; //根据取出的字段让对应的层显示，隐藏其他层
        [_jiXiuBackground setHidden:YES];
        [_penQiBackground setHidden:YES];
    }
    else if([_panDuanGchang isEqualToString:@"喷漆工场"])
    {
        [_penQiBackground addSubview:self.paigongKuaiView];
        [self choosePenqi];
        [_penQiBackground setHidden:NO];  //根据取出的字段让对应的层显示，隐藏其他层
        [_jiXiuBackground setHidden:YES];
        [_banJinBackground setHidden:YES];
    }
    //派工图标上添加按钮
    [self.paigongKuaiView.xinZeng addTarget:self action:@selector(xinZeng:) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - 派工图标点击按钮的回调
-(void)xinZeng:(id)sender
{
    webService *web = [[webService alloc]init];
    web.methodName = GETDISPATCHINGDETAIL;
    
    NSMutableArray *array = [NSMutableArray arrayWithObjects:@"jobSheetId",_jobSheetId,@"itemNo",_itemNo,nil];
    [web commonGetSharedRequest:GETDISPATCHINGDETAIL wsparas:array];
//    NSLog(@"()()()()()()()()()()()%@",_jobSheetId);
}
-(void)getDispatchingDetail:(NSNotification*)notification//派工详细页面
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
    self.paigongXiuGaiViewController = nil;
    self.paigongXiuGaiViewController = [[PaigongXiuGaiViewController alloc]init];
    self.paigongXiuGaiViewController.baoCunDataDit = theJson;
    [self presentPopupViewController:self.paigongXiuGaiViewController animationType:MJPopupViewAnimationFade];    
}

-(void)adddispatchingX:(NSString *)estimatedStartTime adddispatchingY:(NSString *)estimatedEndTime
{
    
}
-(void)passTime:(NSMutableDictionary *)aText
{
    self.passDictionary = aText;
    
    NSString *str1 = [self.passDictionary valueForKey:@"estimatedStartTime"];
    NSString *shi1 = [str1 substringWithRange:NSMakeRange(11, 3)];
    NSString *fen1 = [str1 substringWithRange:NSMakeRange(14, 2)];
    float floatshi1 = [shi1 floatValue];
    float floatfen1 = [fen1 floatValue];
    float Time = (floatshi1*60+floatfen1)*1.1;
    self.startingPoint = [[NSNumber alloc]init];
    self.startingPoint = [NSNumber numberWithFloat:Time];
    
//    NSLog(@"****!!*!*!*!*!!%@",self.startingPoint);
    NSString *str2 = [self.passDictionary valueForKey:@"estimatedEndTime"];
    NSString *shi2 = [str2 substringWithRange:NSMakeRange(11, 3)];
    NSString *fen2 = [str2 substringWithRange:NSMakeRange(14, 2)];
    float floatshi2 = [shi2 floatValue];
    float floatfen2 = [fen2 floatValue];
    float endTime = (floatshi2*60+floatfen2)*1.1;
    self.endPoint = [[NSNumber alloc]init];
    self.endPoint = [NSNumber numberWithFloat:endTime];
//    NSLog(@"****!!*!*!*!*!!%@",self.endPoint);
    float wide = endTime-Time;
    self.viewWide = [[NSNumber alloc]init];
    self.viewWide = [NSNumber numberWithFloat:wide];
    
    [self adddispatching];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
//机修视图切换
-(void)chooseJixiu
{
    _ShaBiZhaoShaoFeiOne = YES;
    _ShaBiZhaoShaoFeiTow = NO;
    _ShaBiZhaoShaoFeiTheer = NO;
    [self.chooseTableButton1 setImage:[UIImage imageNamed:@"ht已选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton2 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton3 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
}
//钣金视图切换
-(void)chooseBanjin
{
    _ShaBiZhaoShaoFeiOne = NO;
    _ShaBiZhaoShaoFeiTow = YES;
    _ShaBiZhaoShaoFeiTheer = NO;
    [self.chooseTableButton2 setImage:[UIImage imageNamed:@"ht已选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton1 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton3 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
}
//喷漆视图切换
-(void)choosePenqi
{
    _ShaBiZhaoShaoFeiOne = NO;
    _ShaBiZhaoShaoFeiTow = NO;
    _ShaBiZhaoShaoFeiTheer = YES;
    [self.chooseTableButton3 setImage:[UIImage imageNamed:@"ht已选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton1 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
    [self.chooseTableButton2 setImage:[UIImage imageNamed:@"ht未选中.png"] forState:UIControlStateNormal];
}
//判断接口返回参数对应哪个层
-(void)panDuan
{
    if([_weiXiutype isEqualToString:@"0"])
    {
//        NSLog(@"_ _ _ _ _ _ _ _ _机修");

        [_jiXiuBackground addSubview:self.paigongKuaiView];
    }
    else if([_weiXiutype isEqualToString:@"1"])
    {
//        NSLog(@"_ _ _ _ _ _ _ _ _钣金");

        [_banJinBackground addSubview:self.paigongKuaiView];

    }
    else if([_weiXiutype isEqualToString:@"2"])
    {
//        NSLog(@"_ _ _ _ _ _ _ _ _喷漆");
        [_penQiBackground addSubview:self.paigongKuaiView];
    }

}
//移除新增派工窗口关闭的通知
-(void)removeObserver
{
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"cancelButtonClicked" object:nil];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:GETWORKSTATIONLIST object:nil];
}
-(void)modifyInstead
{
    [self.paigongButton setHidden:YES];
    [self.homeButton setHidden:YES];
    
    self.homeButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.homeButton1 setImage:[UIImage imageNamed:@"返回.png"] forState:UIControlStateNormal];
    [self.homeButton1 setFrame:CGRectMake(75, 32, 45, 60)];
    [self.homeButton1 addTarget:self action:@selector(homeButton1:) forControlEvents:UIControlEventTouchUpInside];
    [self.serviceScrollView addSubview:self.homeButton1];
}

-(void)homeButton1:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
-(void)addNotification
{
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getDispatchinglist:) name:GETDISPATCHINGLIST object:nil];//派工作业单查询
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getDispatchingDetail:) name:GETDISPATCHINGDETAIL object:nil];//派工详细页面
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getDispatchingViewList:) name:GETDISPATCHINGVIEWLIST object:nil];//派工分类查询
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getworkStationList:) name:GETWORKSTATIONLIST object:Nil];   //工位
}
-(void)removeNotification
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
-(void)dismissPopupViewControllerWithanimationType:(MJPopupViewAnimation)animationType
{
    [self.serviceCompileViewController removeNotification];
    [super dismissPopupViewControllerWithanimationType:animationType];
}
-(void)caoNiMaZhaoShaoFei
{

}

//派工 的数据信息
-(void)paigongByDispatchingData:(NSDictionary *)dicDispatchingData
{
    _jobSheetId = [dicDispatchingData objectForKey:@"jobSheetId"];
    _naoguoqu = [NSMutableDictionary dictionaryWithDictionary:dicDispatchingData];
}

@end
